package Spring;
import java.awt.*;
import javax.swing.*;
/**
 * @Description:
 * @Author:AMark
 * @Date: 10/17/2023
 */
public class SwingFrame {
    //初始化窗口
    private JFrame frame;
    //标签类
    private JLabel labelUserName, labelPassword;
    private JTextField textFieldUserName;
    private JButton buttonLogin, buttonReset;
    private JPasswordField passwordField;
    SwingFrame(String title) {
        //创建框架
        frame = new JFrame(title);
        //设置框架大小
        frame.setSize(260, 180);
        //设置密码的标签
        labelPassword = new JLabel("密码");
        //设置用户名标签
        labelUserName = new JLabel("用户名");
        passwordField = new JPasswordField(10);
        textFieldUserName = new JTextField(10);
        buttonLogin = new JButton("登录");
        buttonReset = new JButton("重置");
        //设置布局管理器
        frame.getContentPane().setLayout(new FlowLayout());
        //将内容添加到框架中
        frame.add(labelUserName);
        frame.add(textFieldUserName);
        frame.add(passwordField);
        frame.add(buttonLogin);
        frame.add(buttonReset);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
class Test {
    public static void main(String[] args) {
        new SwingFrame("登录");
    }
}
